import React from 'react'
import {
    ActivityIndicator,
    View,
    Text
} from 'react-native'
import commonStyle from '../../config'

export const Loading = ({ isLoading = false, msg = '加载中...' }) => {
    if (isLoading == false) {
        return null
    }

    return (
        <View style={{
            position: 'absolute',
            width: '100%',
            height: '100%',
            justifyContent: 'center',
            alignItems: 'center',
        }}>
            <View style={{
                width: 120,
                height: 120,
                justifyContent: 'center',
                alignItems: 'center',
                backgroundColor: 'rgba(0, 0, 0, 0.6)',
                borderRadius: 2,
            }}>
                <ActivityIndicator
                    animating
                    color={commonStyle.themeColor}
                    size={'large'}
                />
                {msg && msg.length > 0 && <Text style={{ marginTop: 12, fontSize: 12, color: '#fff', }}>{msg}</Text>}
            </View>
        </View >
    )
}
